package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.service.VacationService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @描述 考勤管理-->请假管理2.0
 * @创建人 zm
 * @创建时间 2020/3/26
 */
@RestController
@RequestMapping("/vacation")
public class VacationTwoController {


    private Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
    private VacationService service;

    /**
     * @Author zm
     * @Description web请假统计2.0
     * @Date 2020/8/13 18:50
     */
    @RequestMapping("/queryStudentVacationList")
    public Result queryStudentVacationList(RequestParameterWrapper request,
                                           @RequestParam(value = "classIds") String classIds,//班级id 多个格式 “1,2,3,4”
                                           @RequestParam(value = "name", required = false) String name,//学生名字
                                           @RequestParam(value = "stime") String stime,//开始时间
                                           @RequestParam(value = "etime") String etime,//结束时间
                                           @RequestParam(value = "indexNo", required = false, defaultValue = "1") Integer indexNo,
                                           @RequestParam(value = "rows", required = false, defaultValue = "20") Integer rows,
                                           @RequestParam(value = "tSequence", required = false, defaultValue = "0") Integer tSequence,//时间排序
                                           @RequestParam(value = "zSequence", required = false, defaultValue = "0") Integer zSequence) {//请假总次数排序

        String schoolId = request.getParam("schoolId");
        logger.info("VacationTwoController2.0==>queryStudentVacationAll,schoolId={}", schoolId);
        return service.queryStudentVacationList(classIds, name, stime, etime, indexNo, rows, tSequence, zSequence, Integer.parseInt(schoolId));
    }


    /**
     * @Author zm
     * @Description 添加审批人
     * @Date 2020/8/14 10:31
     */
    @RequestMapping("/addApprover")
    public Result addApprover(RequestParameterWrapper request,
                              @RequestParam(value = "one_roles_id") Integer one_roles_id,
                              @RequestParam(value = "two_roles_id", required = false) Integer two_roles_id) {
        String schoolId = request.getParam("schoolId");
        logger.info("VacationTwoController2.0==>addApprover,schoolId={}", schoolId);
        return service.addApprover(Integer.parseInt(schoolId), one_roles_id, two_roles_id);
    }

    /** 查询请假
     * @Author zm
     * @Description
     * @Date 2020/8/21 17:20
     */
    @RequestMapping("/queryApprover")
    public Result queryApprover(RequestParameterWrapper request) {
        String schoolId = request.getParam("schoolId");
        logger.info("VacationTwoController2.0==>addApprover,schoolId={}", schoolId);
        return service.queryApprover(Integer.parseInt(schoolId));
    }

}
